package com.topdt.jbpm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.topdt.jbpm.dao.CommentDao;
import com.topdt.jbpm.model.WorkOpinion;

@Service
@Transactional(readOnly = true)
public class CommentService {
	@Autowired
	private CommentDao commentDao;
	
	@Transactional(readOnly = false)
	public void saveorUpdate(WorkOpinion work) {
		commentDao.save(work);
	}
	@Transactional(readOnly = false)
	public void update(WorkOpinion work) {
		commentDao.update(work);
	}
	/**
	 * 根据工作id取得意见列表
	 * 建立日期 : June 25, 2013 5:41:50 PM<br>
	 * 作者 : wangamin<br>
	 * @return
	 */
	public List<WorkOpinion> getWorkOPioionsByWorkId(String workId) {
		return commentDao.findByWorkId(workId);
	}
	/**
	 * 根据工作id 人员id取得意见列表
	 * 建立日期 : June 25, 2013 5:41:50 PM<br>
	 * 作者 : wangamin<br>
	 * @return
	 */
	public WorkOpinion getWorkOPioionsByTodoIdPid(String todoId,
			String personnelId) {
		return commentDao.getWorkOPioionsByTodoIdPid(todoId,personnelId);
	}
	/**
	 * 根据opinionid取得意见列表
	 * 建立日期 : June 25, 2013 5:41:50 PM<br>
	 * 作者 : wangamin<br>
	 * @return
	 */
	public WorkOpinion getWorkOPioionsByOpinionId(String opinionId) {
		// TODO Auto-generated method stub
		return commentDao.getWorkOPioionsByOpinionId(opinionId);
	}
	
	public List<WorkOpinion> findByOpinionName(String opinionName, String appId, String flowId, String workId) {
		return commentDao.findByOpinionName(opinionName, appId, flowId, workId);
	}

	
}